<template>
  <div class="tab-view">
    <div
      class="tab-item"
      :class="{ active: val == index }"
      @click="handleTabChange(index)"
      v-for="(item, index) in list"
      :key="index"
    >
      {{ item }}
    </div>
  </div>
</template>

<script>
export default {
  model: {
    prop: "value",
    event: "updateValue",
  },
  props: {
    list: {
      type: Array,
      default() {
        return ["全部", "转入", "转出"];
      },
      required: false,
    },
    value: {
      type: [Number, String],
      default() {
        return "";
      },
    },
  },
  data() {
    return {
      val: this.value,
    };
  },
  methods: {
    handleTabChange(index) {
      this.val = index;
      this.$emit("updateValue", this.val);
    },
  },
};
</script>

<style lang="scss" scoped>
.tab-view {
  display: flex;
  align-items: center;
  .tab-item {
    height: 52px;
    background: #f4f6fa;
    border-radius: 8px;
    text-align: center;
    font-size: 24px;
    font-weight: 400;
    color: #919191;
    font-weight: 400;
    margin-right: 20px;
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    &.active {
      background: #0762ff;
      color: #fff;
    }
  }
}
</style>
